//创作级别设置

import React, { useEffect, useState } from 'react';
import { getchuangzuodengji } from '../../utils/api';
import { getcreativelv } from '../../utils/types/home';
import axios from 'axios';
import Tbale from '../ContentManagement/content_components/Tbale';
import moment from 'moment';
import { Tag, Button } from 'antd';
import Toptitle from '../../Compon/Toptitle';
import UploadFile from '../../Compon/UploadFile';
import Gooutfile from '../../Compon/file/Gooutfile.jsx';
export default function AuthoringLevel() {
  const [data, setdata] = useState<getcreativelv[]>([]);
  const [data1, setdata1] = useState<getcreativelv[]>([]);
  const getchuangzuojibie_list = async () => {
    const data = await axios.get<getcreativelv>(
      'http://localhost:3000/CustomerService/index/getchuangzuodengji',
    );
    // const data = await getchuangzuodengji();
    // console.log(data.data.data1);
    // console.log(data.data.data);

    setdata(data.data.data);
    setdata1(data.data.data1);
  };
  useEffect(() => {
    // console.log('创作级别设置');
    getchuangzuojibie_list();
  }, []);
  const columns = [
    {
      title: '序号',
      dataIndex: 'seq',
      key: 'seq',
      render: (text: any, record: any, index: any) => {
        return index + 1;
      },
    },
    {
      title: '级别',
      dataIndex: 'level',
      key: 'level',
    },
    {
      title: '等级标题',
      dataIndex: 'level_name',
      key: 'level_name',
    },
    {
      title: '分成比例',
      dataIndex: '',
      key: '',
      render: (text: any, record: any) => {
        return <span>20%</span>;
      },
    },
    {
      title: '长视频上传数量',
      dataIndex: '',
      key: '',
      render: (text: any, record: any) => {
        return (
          <span>
            {/* return
          {data1.filter((item) => item.shop_type.name == '长视频').length} */}
            2
          </span>
        );
      },
    },
    {
      title: '短视频上传数量',
      dataIndex: 'level',
      key: 'level',
      render: (text: any, record: any) => {
        return (
          <span>
            {/* {
              // data1.filter(
              //   (item) => item.level == text,
              //   // &&
              //   // item.shop_type.name == '短视频',
              // ).length
            } */}
            2
          </span>
        );
      },
    },
    {
      title: '时间',
      dataIndex: 'level_time',
      key: 'level_time',
      render: (text: any, record: any) => {
        return <span>{moment(text).format('YYYY-MM-DD HH:mm:ss')}</span>;
      },
    },
    {
      title: '状态',
      dataIndex: 'level_state',
      key: 'level_state',
      render: (text: any, record: any) => {
        return (
          <Tag color={text == 1 ? 'green' : 'red'}>
            {text == 1 ? '启用' : '禁用'}
          </Tag>
        );
      },
    },
    {
      title: '操作',
      dataIndex: 'level_state',
      key: 'level_state',
      render: (text: any, record: any) => {
        return (
          <span>
            <Button
              type="primary"
              onClick={() => {
                a();
              }}
            >
              编辑
            </Button>
            <Button type="primary" danger>
              删除
            </Button>
          </span>
        );
      },
    },
  ];
  const a = () => {
    alert('编辑');
  };
  return (
    <div>
      <Toptitle title="创作级别管理"></Toptitle>
      <Tbale data={data} colums={columns}></Tbale>
      <div style={{ display: 'flex' }}>
        <UploadFile
          name={'导入'}
          // url="http://localhost:3000/CustomerService/index/uploadFile"
        ></UploadFile>
        <Gooutfile data={data}></Gooutfile>
      </div>
    </div>
  );
}
     